import axios from 'axios'
import { Loading } from 'element-ui';
export default{
  
  

 
  install(Vue){
    let loadingInstance;
    var token=localStorage.getItem('token')
    // 请求拦截器
    axios.interceptors.request.use(function (config){
      // 显示  loading 
      loadingInstance=Loading.service({
        fullscreen:true,
        text:"努力加载中...",
        background:"rgba(0,0,0,0.7)"
      })  
      config.headers.Authorization=token
      return config
    })
    // 响应拦截器  
    axios.interceptors.response.use(function (response) {
      // 隐藏  loading
      loadingInstance.close()
      return response
    })

    Vue.prototype.$http=async function({url,method,data}){
      return axios({
        url,
        method,
        data
      })
    }
  }

 


}

